package com.itheima;

public class Test05 {
    //有以下数组，存储了六名员工的年龄：
    //int[] arr = {31,42,23,64,25,36};
    //请定义方法getCount()，计算数组中：大于平均年龄的员工有多少人。

    public static void main(String[] args) {
        int[] arr = {21, 22, 23, 24, 25, 26};

        int count = getCount(arr);

        System.out.println("大于平均年龄的员工有" + count + "人");

    }

    public static int getCount(int[] arr) {
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }

        double avg = sum / arr.length;
        int count = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > avg) {
                count++;
            }

        }
        return count;
    }

}
